﻿using Iworld.Game.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace Iworld.Game.Service.Client.Export
{
    /// <summary>
    /// 牌轮信息输出
    /// </summary>
    [DataContract]
    public class GameChapterExport
    {

        public GameChapterExport(GameChapter game,GameChapter lastGame = null)
        {
            if (game == null) return;
            this.ActiveTime = game.ActiveTime;
            this.ChapterNumber = game.ChapterNumber;
            this.CurrentRoundNumber = game.CurrentRoundNumber;
            this.NextRoundNumber = game.NextRoundNumber;
            this.NextRoundLotteryTime = game.NextRoundLotteryTime;
            this.TotalRoundCount = game.TotalRoundCount;
            this.Status = game.Status;
            if (lastGame != null)
            {
                this.LastGame = new GameChapterExport(lastGame);
            }
            this.GameRounds = new List<GameRoundExport>();
             game.GameRounds.Where(x=>x.IsLottery).ToList().ForEach((x)=>{
                 this.GameRounds.Add(new GameRoundExport(x));
            });
        }

        /// <summary>
        /// 上一轮已经开奖结束的信息(如果有)
        /// </summary>
        [DataMember]
        public GameChapterExport LastGame { set; get; }

        /// <summary>
        /// 牌轮激活的时间
        /// </summary>
        [DataMember]
        public DateTime? ActiveTime { get; set; }

        /// <summary>
        /// 牌局信息
        /// </summary>
        [DataMember]
        public List<GameRoundExport> GameRounds { set; get; }

        /// <summary>
        /// 轮号
        /// </summary>
        [DataMember]
        public int ChapterNumber { get; set; }

        /// <summary>
        /// 当前开奖的局号
        /// </summary>
        [DataMember]
        public int? CurrentRoundNumber { get; set; }

        /// <summary>
        /// 下次开奖的局号
        /// </summary>
        [DataMember]
        public int? NextRoundNumber { get; set; }

        /// <summary>
        /// 下次开奖的时间
        /// </summary>
        [DataMember]
        public DateTime? NextRoundLotteryTime { get; set; }

        /// <summary>
        /// 本轮总局数
        /// </summary>
        [DataMember]
        public int TotalRoundCount { get; set; }

        /// <summary>
        /// 牌轮状态
        /// </summary>
        [DataMember]
        public GameChapterStatus Status { get; set; }
    }
}
